/**
 * 
 */
var ManagerOrderListController = function($scope, $http, PaginatorRR, $log) {
	$scope.pageSize = 10;
	$scope.orders = [];
	var fetchFunction = function(currentPage, limit, propId, callback) {

		$http.get("../managerOrder/waitSend", {
			params : {
				'pageSize' : limit,
				'cpage' : currentPage,
			}
		}).success(callback);
	}

	$scope.orders[0] = PaginatorRR(fetchFunction, $scope.pageSize, 0);
	$log.info($scope.orders);

	$scope.edit = function(obj) {

		if (obj.orderProp.id == 3) {
			obj.showOperator = true;

		} else {
			obj.showOperator = false;
		}

		$scope.norder = obj;
		$scope.showOperatorDetail = false;
		$scope.operator = "";
		$("#new_ui").offCanvas('open');
	}

	/**
	 * 关闭侧边栏
	 */
	$scope.closeNew = function() {

		$scope.showOperator = false;
		$("#new_ui").offCanvas('close');
	}

	$scope.send = function(order) {
		$http({
			method : "post",
			url : "../managerOrder/sendProduct",
			data : $.param({
				'uuid' : order.uuid
			}), // pass in data as strings
			headers : {
				'Content-Type' : 'application/x-www-form-urlencoded'
			}
		}).success(function(response) {
			if (response.code == 1) {
				sweetAlert("发货成功");
				$scope.orders[0] = PaginatorRR(fetchFunction, $scope.pageSize, 0);
			} else {
				sweetAlert(response.info);
				return;
			}
		});
	}
}